package com.tang.usercenter.common.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class ConstantFinalUtil {

    public static Logger LOGGER = LogManager.getLogger(ConstantFinalUtil.class);
    
    public static JSONObject RESOURCE_JSON = new JSONObject();
    
    public static JSONObject INFO_JSON = new JSONObject();
    
    /* 静态代码块:初始化一次 */
	static
	{
		/* 读取JSON配置文件 */
		FileUtil fileUtil = new FileUtil();
		try
		{
			String resourceStr = fileUtil.readFile(ConstantFinalUtil.class.getClassLoader().getResourceAsStream("config.json"));
			RESOURCE_JSON = (JSONObject) JSON.parse(resourceStr);
			
			/* 获取json配置文件中info信息 */
			INFO_JSON = RESOURCE_JSON.getJSONObject("info");
			ConstantFinalUtil.LOGGER.info("JSON配置文件初始化");
		} catch (Exception e)
		{
			ConstantFinalUtil.LOGGER.info("JSON配置文件转换报错了",e);
		}
	}
}
